from tencentcloud.common import credential
from tencentcloud.sms.v20210111 import sms_client, models

cred = credential.Credential("AKID33tZBew30n5DBzd8TfgYGoCPTMD1f9Uf", "75uZ4PbeXGpETbZOqJdmlaEj5IMI5iBa")
client = sms_client.SmsClient(cred, "ap-guangzhou")

req = models.SendSmsRequest()

req.SmsSdkAppId = "1400935775"
req.SignName = "合肥起风网络科技有限公司"
req.TemplateId = "2304391"
req.TemplateParamSet = ["449739"]
req.PhoneNumberSet = ["+866605643102"]

resp = client.SendSms(req)
print(resp, type(resp))
print(resp.SendStatusSet, type(resp.SendStatusSet))
from tencentcloud.sms.v20210111.models import SendSmsResponse
# {"SendStatusSet": [{"SerialNo": "2640:262727967816586500757778766", "PhoneNumber": "+8618630087660", "Fee": 1, "SessionContext": "", "Code": "Ok", "Message": "send success", "IsoCode": "CN"}], "RequestId": "5528d8e4-31c3-41e3-9e6b-ef8006f365cd"}

# [{"SerialNo": "", "PhoneNumber": "+8618630087660", "Fee": 0, "SessionContext": "", "Code": "LimitExceeded.PhoneNumberThirtySecondLimit", "Message": "the number of SMS messages sent from a single mobile number within 30 seconds exceeds the upper limit", "IsoCode": "CN"}] <class 'list'>
# [{"SerialNo": "2640:133731727416586503152335508", "PhoneNumber": "+8615131255089", "Fee": 1, "SessionContext": "", "Code": "Ok", "Message": "send success", "IsoCode": "CN"}]



#自己
#1.正常
# {"SendStatusSet": [{"SerialNo": "3363:72243638817353895179664310", "PhoneNumber": "+8616605643102", "Fee": 1, "SessionContext": "", "Code": "Ok", "Message": "send success", "IsoCode": "CN"}], "RequestId": "c2812dae-c479-48e3-9513-ebfa9d6f8002"} <class 'tencentcloud.sms.v20210111.models.SendSmsResponse'>
# [{"SerialNo": "3363:72243638817353895179664310", "PhoneNumber": "+8616605643102", "Fee": 1, "SessionContext": "", "Code": "Ok", "Message": "send success", "IsoCode": "CN"}] <class 'list'>

#2.超过频率限制
# {"SendStatusSet": [{"SerialNo": "", "PhoneNumber": "+8616605643102", "Fee": 0, "SessionContext": "", "Code": "LimitExceeded.PhoneNumberThirtySecondLimit", "Message": "the number of SMS messages sent from a single mobile number within 30 seconds exceeds the upper limit", "IsoCode": "CN"}], "RequestId": "3278a096-75ba-4c84-a6f2-b585d6336b8b"} <class 'tencentcloud.sms.v20210111.models.SendSmsResponse'>
# [{"SerialNo": "", "PhoneNumber": "+8616605643102", "Fee": 0, "SessionContext": "", "Code": "LimitExceeded.PhoneNumberThirtySecondLimit", "Message": "the number of SMS messages sent from a single mobile number within 30 seconds exceeds the upper limit", "IsoCode": "CN"}] <class 'list'>

#3.错误的手机号
# {"SendStatusSet": [{"SerialNo": "", "PhoneNumber": "+866605643102", "Fee": 0, "SessionContext": "", "Code": "InvalidParameterValue.IncorrectPhoneNumber", "Message": "incorrect number format", "IsoCode": "CN"}], "RequestId": "36498594-db59-4301-a98d-063f2c1399a5"} <class 'tencentcloud.sms.v20210111.models.SendSmsResponse'>
# [{"SerialNo": "", "PhoneNumber": "+866605643102", "Fee": 0, "SessionContext": "", "Code": "InvalidParameterValue.IncorrectPhoneNumber", "Message": "incorrect number format", "IsoCode": "CN"}] <class 'list'>